package io.gather

import com.jfinal.config.*
import com.jfinal.ext.annotation.AnnotationBindPlugin
import com.jfinal.plugin.activerecord.ActiveRecordPlugin
import com.jfinal.plugin.druid.DruidPlugin
import com.jfinal.render.ViewType

/**
 * Created with IntelliJ IDEA.
 * User: Ryan
 * Date: 13-8-25
 * Time: 下午2:49
 * To change this template use File | Settings | File Templates.
 */
class Config extends JFinalConfig{
    private Routes routes
    private Handlers handlers
    private Interceptors interceptors
    private Constants constants
    private Plugins plugins


    @Override
    void configConstant(Constants me) {
        this.constants = me
        me.viewType = ViewType.JSP
        me.devMode = true
    }

    @Override
    void configRoute(Routes me) {
        this.routes = me
    }

    @Override
    void configPlugin(Plugins me) {
        this.plugins = me
        DruidPlugin dp = new DruidPlugin("jdbc:mysql:///gather","root" ,"root")
        me.add(dp)
        ActiveRecordPlugin arp = new ActiveRecordPlugin(dp)
        me.add(arp)

        me.add(new AnnotationBindPlugin(this).set(this.routes).set(arp))
    }

    @Override
    void configInterceptor(Interceptors me) {
        this.interceptors = me
    }

    @Override
    void configHandler(Handlers me) {
        this.handlers = me
    }
}
